import { ColorScheme } from '@p/utils';

/**
 * 添加过度类名和css变量
 */
export function addSCST(mode: ColorScheme, ms: number) {
	let add = mode;
	let remove: ColorScheme = mode === 'dark' ? 'light' : 'dark';

	document.documentElement.classList.add('switch-color-scheme-active', 'SCSA');
	document.documentElement.style.setProperty('--SCST', ms + 'ms');

	Promise.resolve().then(() => {
		document.documentElement.classList.add(add);
		document.documentElement.classList.remove(remove);

		setTimeout(() => {
			document.documentElement.classList.remove('switch-color-scheme-active', 'SCSA');
			document.documentElement.style.removeProperty('--SCST');
		}, ms);
	});
}
